#include <iostream>
#include<vector>
using namespace std;

int main() {
    string nums;
    cin>>nums;
    vector<vector<vector<int>>>dp(nums.size(),vector<vector<int>>(nums.size(),vector<int>(2,0)));
    long long sum;
    for(int i=0;i<nums.size();i++){
        for(int j=i;j<nums.size();j++){
            if(j==i) dp[i][j][!(nums[i]-'0')]=1;
            else{
                    dp[i][j][nums[j]-'0']=dp[i][j-1][!(nums[j]-'0')];
                    dp[i][j][!(nums[j]-'0')]=dp[i][j-1][nums[j]-'0']+1;
            }
            sum+=min(dp[i][j][0],dp[i][j][1]);
        }
    }
    cout<<sum;
}
// 64 位输出请用 printf("%lld")